package com.example.mz.dynamicdb.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.example.mz.dynamicdb.entity.Student;
import com.example.mz.dynamicdb.mapper.StudentMapper;
import com.example.mz.dynamicdb.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@DS("DB3307")
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public class StudentServiceIml implements StudentService {


    @Autowired
    public StudentMapper studentMapper;

    @Override
    public List<Student> getStudentList() {
        return studentMapper.getStudentList();
    }

    @Override
    public void addStudent(Student student) {
        studentMapper.addStudent(student);
    }

    @Override
    public void batchAddStudent(List<Student> studentList) {
        studentMapper.batchAddStudent(studentList);

    }
}
